package com.menhai.personmanagement.mapper;

import com.menhai.personmanagement.entity.SysRole;
import org.apache.ibatis.annotations.Mapper;
import com.menhai.personmanagement.entity.SysUser;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author shikun
 * @since 2021-12-09
 */
@Mapper
public interface SysUserMapper extends BaseMapper<SysUser>{

    @Select("select r.id,r.name,r.index,r.powers from sys_user u,sys_role r where u.roleId = r.id and u.id=#{id} and u.isAvailable=1;")
    public List<SysRole> findUserRole(@Param("id") int id);

    @Update("update sys_user set password=#{password} where telephone=#{telephone}")
    public int editPass(@Param("telephone") String telephone,@Param("password") String password);
}
